package com.ptkc.utils;

public class StringUtil {
    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }
    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
    public static Integer stringToInteger(String str){
        Integer i = null;
        if(str!=null){
            i = Integer.valueOf(str);
        }
        return i;
    }
    public static int getInt(String str){//把字符串转换为int类型
        int i = 0;
        try{
            i = Integer.parseInt(str);
        }catch(NumberFormatException ex){}
        return i;
    }

    public static Integer[] split(String strvalue, String ...maybeSplit){
        if(maybeSplit == null || maybeSplit.length == 0){
            return null;
        }
        StringBuilder sbuilder = new StringBuilder();
        for (int i = 0; i < maybeSplit.length; i++) {
            String split = maybeSplit[i];
            sbuilder.append("[^\\d]").append(split).append("|");
        }
        String regex = sbuilder.substring(0, sbuilder.length() - 1);
        String[] valArrays = strvalue.split(regex);
        Integer[] afterSplitIntvalue = new Integer[valArrays.length];
        for(int i = 0; i < valArrays.length; i++){
            afterSplitIntvalue[i] = Integer.valueOf(valArrays[i]);
        }
        return afterSplitIntvalue;
    }

}
